<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-cf">提现申请记录</div>
                </div>
                <div class="widget-body am-fr">
                    <!-- 工具栏 -->
                    <div class="page_toolbar am-margin-bottom-xl am-cf">
                        <form id="form-search" class="toolbar-form" action="">
                            <input type="hidden" name="s" value="/<?= $request->pathinfo() ?>">
                            <div class="am fr">
                                <div class="am-form-group tpl-form-border-form am-fl">
                                    <input type="text" name="start_time"
                                           class="am-form-field"
                                           value="<?= $request->get('start_time') ?>" placeholder="请选择起始日期"
                                           data-am-datepicker>
                                </div>
                                <div class="am-form-group tpl-form-border-form am-fl">
                                    <input type="text" name="end_time"
                                           class="am-form-field"
                                           value="<?= $request->get('end_time') ?>" placeholder="请选择截止日期"
                                           data-am-datepicker>
                                </div>
                                <div class="am-form-group am-fl">
                                    <div class="am-input-group am-input-group-sm tpl-form-border-form">
                                        <input type="text" class="am-form-field" name="search"
                                               placeholder="请输入商户名称"
                                               value="<?= $request->get('search') ?>">
                                        <div class="am-input-group-btn">
                                            <button class="am-btn am-btn-default am-icon-search" type="submit"></button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="am-scrollable-horizontal am-u-sm-12">
                        <table width="100%" class="am-table am-table-compact am-table-striped
                         tpl-table-black am-text-nowrap">
                            <thead>
                            <tr>
                                <th>申请号</th>
                                <th>申请商户</th>
                                <th>提现金额</th>
                                <th>审核状态</th>
                                <th>备注</th>
                                <th>申请时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php if (!$list->isEmpty()): foreach ($list as $item): ?>
                                <tr>
                                    <td class="am-text-middle"><?= $item['id'] ?></td>
                                    <td class="am-text-middle"><?= $item['wxapp']['wxapp_name'];?></td>
                                    <td class="am-text-middle">   <?= $item['money'];?></td>
                                    <td class="am-text-middle">
                                        <?php if ($item['apply_status'] ==10) : ?>
                                            <span class="x-color-default">待通过</span>
                                        <?php elseif ($item['apply_status'] ==20 ) : ?>
                                            <span class="x-color-green">通过</span>
                                        <?php elseif ($item['apply_status'] ==30 ) : ?>
                                            <span class="x-color-red">拒绝</span>

                                        <?php endif; ?>
                                    </td>
                                    <td class="am-text-left">
                                        <?= $item['back_reason'];?>
                                    </td>
                                    <td class="am-text-middle"><?= format_time($item['apply_time']) ?></td>
                                    <td class="am-text-middle">
                                        <div class="tpl-table-black-operation">
                                            <?php if ($item['apply_status'] ==10) : ?>
                                                <a href="javascript:void(0);" class="js-down tpl-table-black-operation-del" data-id="<?= $item['id'] ?>">拒绝</a>
                                                <span style="padding-left: 20px"></span>
                                                <a href="javascript:void(0);" class="j-adopt tpl-table-black-operation-edit" data-id="<?= $item['id'] ?>">通过</a>
                                            <?php elseif ($item['apply_status'] ==20) : ?>
                                                <span class="x-color-green">已通过</span>

                                            <?php elseif ($item['apply_status'] ==30) : ?>
                                                <span class="x-color-red">已拒绝</span>
                                            <?php endif; ?>

                                        </div>
                                    </td>
                                </tr>
                            <?php endforeach; else: ?>
                                <tr>
                                    <td colspan="7" class="am-text-center">暂无记录</td>
                                </tr>
                            <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">
                        <div class="am-fr"></div>
                        <div class="am-fr pagination-total am-margin-right">
                            <div class="am-vertical-align-middle">总记录：1</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {

        //打款
       // var aurl = "<?= url('finance.Large/adopt') ?>";
       // $('.j-thaw').delete('id', aurl, '确定要通过吗？');

        // 通过
        var url = "<?= url('finance.Large/thaw') ?>//";
        $('.j-adopt').delete('id', url, '确定要通过吗？');

        // 拒绝
        $('.js-down').click(function () {
            // 验证权限
            if (!"<?= checkPrivilege('finance.Large/refuse')?>") {
                return false;
            }
            var data = $(this).data();
            var str="<div class=\"row-content am-cf\">\n" +
                "    <div class=\"row\">\n" +
                "        <div class=\"am-u-sm-12 am-u-md-12 am-u-lg-12\">\n" +
                "            <div class=\"widget am-cf\">\n" +
                "                <form id=\"my-form\" class=\"am-form tpl-form-line-form\" method=\"post\">\n" +
                "                    <div class=\"widget-body\">\n" +
                "                        <fieldset>\n" +
                "                            <div class=\"am-form-group\">\n" +
                "                                <label class=\"am-u-sm-3 am-u-lg-2 am-form-label form-require\">消息标题  </label>\n" +
                "                                <div class=\"am-u-sm-9 am-u-end\">\n" +
                "                                    <input type=\"text\" id='title' class=\"tpl-form-input\" name=\"message_title\"\n" +
                "                                           value=\"\" required>\n" +
                "                                </div>\n" +
                "                            </div>\n" +
                "                            <div class=\"am-form-group\">\n" +
                "                                <label class=\"am-u-sm-3 am-u-lg-2 am-form-label form-require\">原因描述 </label>\n" +
                "                                <div class=\"am-u-sm-9 am-u-end\">\n" +
                "                                    <textarea cols=\"100\" rows=\"10\"  id='content' name=\"message_content\"></textarea>\n" +
                "                                </div>\n" +
                "                            </div>\n" +
                "                        </fieldset>\n" +
                "                    </div>\n" +
                "                </form>\n" +
                "            </div>\n" +
                "        </div>\n" +
                "    </div>\n" +
                "</div>";

            layer.confirm(str,{btn: ['确定', '取消'], area:["700px","500px"], title: "回复"}, function (index, layero) {
                var title = $(layero).find('#title').val();
                var content = $(layero).find('#content').val();;
                $.post("<?= url('finance.Large/refuse') ?>"
                    , {
                        id: data.id,
                        message_title:title,
                        message_content:content,
                    }
                    , function (result) {
                        result.code === 1 ? $.show_success(result.msg, result.url) : $.show_error(result.msg);
                    });
                layer.close(index);
            });
        });



    });
</script>
